import type { DataTableProps } from "naive-ui";
import { NAvatar, NImage, NTag } from "naive-ui";
import { h } from "vue";
import RenderGender from "@/components/RenderGender.vue";
import { formatTime, renderMaybeNull } from "@/utils";
import { AUTH_TYPE_MAP, USER_AUTH_STATUS_MAP, USER_AUTH_STATUS_MAP_COLOR } from '@/const/user'

export const tenantColumns: DataTableProps["columns"] = [
	{
		title: '租户名',
		key: 'tenantName',
		width: 120
	},
	{
		title: '手机号',
		key: 'phone',
		width: 120
	},
	{
		title: '邮箱',
		key: 'email',
		width: 180
	},
	{
		title: '账号状态',
		key: 'status',
		width: 100,
		render: (row: any) => {
			return h(NTag, {
				type: row.status === 0 ? 'success' : 'error',
				round: true,
				size: 'small'
			}, {
				default: () => row.status === 0 ? '正常' : '停用'
			})
		}
	},
    {
        title: '社会信用代码',
        key: 'socialCreditCode',
        width: 180
    },
    {
        title: '法人',
        key: 'legalPerson',
        width: 180
    },
	{
		title: '创建时间',
		key: 'createTime',
		width: 180,
		render: (row: any) => row.createTime ? formatTime(row.createTime, 'YYYY-MM-DD HH:mm:ss') : '-'
	}
]

export const auditUserColumns: DataTableProps["columns"] = [
	{
		title: '姓名',
		key: 'name',
		width: 80,
		render: item => renderMaybeNull(item.name),
	},
	{
		title: '手机号',
		key: 'phone',
		width: 120,
	},
	{
		title: '身份证号码',
		key: 'idcard',
		width: 200,
	},
	{
		title: '认证类型',
		key: 'type',
		width: 100,
		render: (item: any) => AUTH_TYPE_MAP[item.type] || item.type
	},
	{
		title: '身份证（正面）',
		key: 'idcardFront',
		width: 130,
		render: item => h(NImage, {
			src: item.idcardFront,
			height: 50,
			width: 100,
			objectFit: 'contain',
		})
	},
	{
		title: '身份证（反面）',
		key: 'idcardBack',
		width: 130,
		render: item => h(NImage, {
			src: item.idcardBack,
			height: 50,
			width: 100,
			objectFit: 'contain',
		})
	},
	{
		title: '提交时间',
		key: 'city',
		width: 180,
		render: item => formatTime(item.createTime)
	},
]
